﻿<?xml version="1.0" encoding="utf-8" ?>
<content>
	<mainContent>
		<![CDATA[
		<h2>SiteMap Integration. <span>Those Rules Hurt My Head!</span></h2>
		<p>If your website is using ASP.NET SiteMap providers, DNAide's UrlRewriter works well with these. In addition to defining rewriting rules, you can specify basic rewriting directly within your SiteMap file!</p>
			
		<pre class="csharpcode">
&lt;siteMapNode url=<span class="str">"~/news/dnaide-released.aspx"</span> rewriteToUrl=<span class="str">"~/Templates/WebForms/NewsView.aspx"</span> newsid=<span class="str">"1"</span> /&gt;

&lt;siteMapNode url=<span class="str">"~/news/another-story.aspx"</span> rewriteToUrl=<span class="str">"~/Templates/WebForms/NewsView.aspx"</span> newsid=<span class="str">"2"</span> /&gt;</pre>

		<p>Whats happening here is that we have one aspx template "NewsView.aspx" which is used to display news stories.</p>
			
		<p>Rather than handing out urls such as "news/view.aspx?id=1" etc. we can use "news/dnaide-released.aspx" which in turn is re-written to the "Templates/WebForms/NewsView.aspx" template.</p>
			
		<p>How would "NewsView.aspx" know what story to show if the id is not passed along the url?</p>
			
		<p>To tell the template this, I have added a custom "newsid" attribute to each node:</p>
		<pre class="csharpcode">
<span class="kwrd">int</span> newsId = CastAide.AsInt32(SiteMap.CurrentNode[<span class="str">"newsid"</span>]);</pre>

		<p>Additionally, if you wanted to, your friendly urls could appear to be static html files and have the ".htm" extension rather than the ".aspx" extension. This is achieved by configuring IIS so that the .htm extension is handled by ASP.NET dll or that all extensions are handled by the ASP.NET dll.</p>
		]]>
	</mainContent>

	<secondaryContent>
		<![CDATA[
		]]>
	</secondaryContent>
</content>